<template>
  <div class="layer h-screen gap-3 bg-white">

    <div class="section px-14 pt-34 gap-1 text-center">
      <div class="title-lg">欢迎使用</div>
      <div class="title-4xl text-emerald-500 drop-shadow">鑫毅会员系统</div>
      <div class="">精准管理 高效营销 提升忠诚 助力增长</div>
    </div>

    <div v-if="isRegisted === false" class="section px-14 pt-20 gap-6">

      <div class="btn-primary" @click="handleClickRegister">
        <div class="icon-xl i-mdi-arrow-right-thin-circle-outline animate-pulse"></div>
        <div class="text-white">立即注册</div>
      </div>

      <div class="text-center text-emerald-500 underline" @click="handleClickTrail">游客试用</div>

    </div>

    <div class="mt-10 section center">
      <div class="desc">--- 鑫毅智慧 卓越赋能 ---</div>
    </div>

  </div>
</template>

<script setup lang="ts">

import { computed, nextTick, onMounted, ref } from 'vue'
import useLogin from '@/hooks/useLogin'
import { goto } from '@/utils'

const { login } = useLogin()

const token = ref('')

onMounted(() => {
  nextTick(() => {
    uni.showLoading({
      title: '加载中...',
      mask: true,
    })
    setTimeout(() => {
      const token = uni.getStorageSync('token')
      console.log('token => ', token);
      if (token) {
        login()
      }
      uni.hideLoading()
    }, 1000);
  })
})

const handleClickRegister = () => {
  goto('./register')
}

const handleClickTrail = () => {
  goto('./index')
}

const isRegisted = computed(() => {
  return token.value !== ''
})

</script>

<style></style>
